"""
pandas 复习01
"""
import pandas as pd
import numpy as np

# s = pd.Series()
# print(s)
# data = np.array(['张三','李四','王五','赵六'])
# s1 = pd.Series(data)
# print(s1)
# s2 = pd.Series(data,index=['100','101','102','103'])
# print(s2)
# data = {'100':'张三','101':'李四','102':'王五'}
# s3 = pd.Series(data)
# print(s3)
# s4 = pd.Series(5,index=[0,1,2,3])
# print(s4)

# # 使用索引检索数据
# s = pd.Series([1,2,3,4,5],index=['a','b','c','d','e'])
# print(s[0])
# print(s[:3])
# print(s[-3:])
#
# #使用标签索引检索数据
# print(s['a'])
# print(s[['a','b','c']])


# DataFrame
# df = pd.DataFrame()
# print(df)
#
# data = [1,2,3,4,5]
# df1 = pd.DataFrame(data)
# print(df1)

# data = [['Alex',10],['Bob',12],['Clarke',13]]
# df = pd.DataFrame(data,columns=['Name','Age'])
# print(df)

# data = [{'a':1,'b':2},{'a':5,'b':10,'c':20}]
# df = pd.DataFrame(data)
# print(df)

# data = {'Name': ['Tom','Jack','Steve','Kimi'],'age':[28,29,30,32]}
# df = pd.DataFrame(data)
# print(df)
#
# df1 = pd.DataFrame(data,index=['s1','s2','s3','s4'])
# print(df1)

# data = {'one':pd.Series([1,2,3],index=['a','b','c']),
#         'two':pd.Series([1,2,3,4],index=['a','b','c','d'])}
# df = pd.DataFrame(data)
# print(df)

# data = {'one': pd.Series([1,2,3],index=['a','b','c']),
#         'two': pd.Series([1,2,3,4],index=['a','b','c','d']),
#         'three': pd.Series([1,3,4],index=['a','c','d'])}
#
# df = pd.DataFrame(data)
# print(df)
# 列的操作
# 列的访问
# print(df['one'])
# print(df[df.columns[:2]])
# 列的新增
# df['four'] = pd.Series([90,80,70,60],index=['a','b','c','d'])
# print(df)
# # 列的修改
# df['four'] = pd.Series([666,777,888,999],index=['a','b','c','d'])
# print(df)
# # 列的删除
# del(df['four'])
# df.pop('four')

data = d = {'one' : pd.Series([1, 2, 3], index=['a', 'b', 'c']),
    'two' : pd.Series([1, 2, 3, 4], index=['a', 'b', 'c', 'd'])}

df = pd.DataFrame(data)
print(df)

# 行的操作
# print(df[2:4])
#
# print(df.loc['b'])
#
# print(df.loc[['a','b']])

print(df.iloc[2])

print(df.iloc[[2,3]])


